
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QDebug>
#include <QThread>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    chat_client(ChatClient::getChatClientInstance())
{
    ui->setupUi(this);
    dialog = new Chatting_room;
    QObject::connect(this,SIGNAL(getFriendMessages(QString,Chatting_room *)),dialog,SLOT(getInfo(QString,Chatting_room *)));
    //QObject::connect(this, SIGNAL(login_click))
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_chatting_clicked()
{

    QString ip = ui->IPAddress->text();

    //QThread::msleep(10);

    emit getFriendMessages(ip,dialog);

    //dialog->show();
   // QObject::disconnect(this, SIGNAL(getFriendMessages(QString,Chatting_room *)),dialog,SLOT(getInfo(QString,Chatting_room *)));
}

void MainWindow::on_offline_clicked()
{
    this->close();
}
